package com.zxsc.zxmusic.adapter;

import java.util.List;

import com.zxsc.zxmusic.R;
import com.zxsc.zxmusic.model.SongMenuModel;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AdapterDialog extends BaseAdapter{

	private List<SongMenuModel> menus;
	private Context context;
	
	public AdapterDialog(Context context,List<SongMenuModel> menus) {
		this.context=context;
		this.menus=menus;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return menus.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return menus.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		GroupViewHolder viewHolder=null;
		if(convertView==null){
			viewHolder=new GroupViewHolder();
			convertView=LayoutInflater.from(context).inflate(R.layout.item_songmenu, parent,false);
			viewHolder.arrowsImage=(ImageView) convertView.findViewById(R.id.songmenu_arrow);
			viewHolder.txtSongMenuName=(TextView) convertView.findViewById(R.id.songmenu_name);
			viewHolder.txtSongCount=(TextView) convertView.findViewById(R.id.songmenu_count);
			convertView.setTag(viewHolder);
		}else{
			viewHolder=(GroupViewHolder) convertView.getTag();
		}
		
		viewHolder.txtSongCount.setVisibility(View.GONE);
		SongMenuModel menuModel=menus.get(position);
		viewHolder.txtSongMenuName.setText(menuModel.getMenuName());
		viewHolder.txtSongCount.setText(menuModel.getSongCount()+"");
		return convertView;
	}
	
	class GroupViewHolder{
		ImageView arrowsImage;
		TextView txtSongMenuName;
		TextView txtSongCount;
	}

}
